﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using U.B.ErrorCode;
using U.B.WriteApi.Command;
using U.B.WriteApi.Command;

namespace U.B.WriteApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AdduserController : ControllerBase
    {

        private readonly IMediator _mediator;

        public AdduserController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<object>>Adduser( AdduserCommand command)
        {
            return _mediator.Send(command);
        }
        /// <summary>
        /// 更新用户角色
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public  async Task<ApiResult<object>> updateuser(UpdateuserroleCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
